# Patch for SwapXT (by bulletxt) and Wall Tile Extension v4.13 (by Moon Man)
# Patch v1.0.0
# Patch written by Mithos (credit please =D)

# Only tested with the above versions of the scripts.

#===============================
# INSTRUCTIONS
#===============================
# Install scripts in the following order:
# SwapXT
# VX_SP1
# Wall Tile Extension
# Patch

#===============================
# Do not edit beyond this point
#===============================

class Spriteset_Map
  alias :mithos_patch_create_tilemap :create_tilemap unless $@
  def create_tilemap
    mithos_patch_create_tilemap
    setup_shadow_eraser_tilemap

    #tileA1
    if $tileA1 == "empty::*::"
      @ex_tilemap.bitmaps[0] = Cache.system("TileA1")
    else
      tile1 = Cache_Swap_Tiles.swap($tileA1 + ".png") rescue nil
      @ex_tilemap.bitmaps[0] = tile1 if $tileA1 != nil
    end
  
    #tileA2
    if $tileA2 == "empty::*::"
      @ex_tilemap.bitmaps[1] = Cache.system("TileA2")
    else
      tile2 = Cache_Swap_Tiles.swap($tileA2 + ".png") rescue nil
      @ex_tilemap.bitmaps[1] = tile2 if $tileA2 != nil
    end
    
    #tileA3
    if $tileA3 == "empty::*::"
      @ex_tilemap.bitmaps[2] = Cache.system("TileA3")
    else
      tile3 = Cache_Swap_Tiles.swap($tileA3 + ".png") rescue nil
      @ex_tilemap.bitmaps[2] = tile3 if $tileA3 != nil
    end
      
    #tileA4
    if $tileA4 == "empty::*::"
      @ex_tilemap.bitmaps[3] = Cache.system("TileA4")
    else
      tile4 = Cache_Swap_Tiles.swap($tileA4 + ".png") rescue nil
      @ex_tilemap.bitmaps[3] = tile4 if $tileA4 != nil
    end
      
    #tileA5
    if $tileA5 == "empty::*::"
      @ex_tilemap.bitmaps[4] = Cache.system("TileA5")
    else
      tile5 = Cache_Swap_Tiles.swap($tileA5 + ".png") rescue nil
      @ex_tilemap.bitmaps[4] = tile5 if $tileA5 != nil
    end

    #tileB
    if $tileB == "empty::*::"
      @ex_tilemap.bitmaps[5] = Cache.system("TileB")
    else
      tile6 = Cache_Swap_Tiles.swap($tileB + ".png") rescue nil
      @ex_tilemap.bitmaps[5] = tile6 if $tileB != nil
    end

    #tileC
    if $tileC == "empty::*::"
      @ex_tilemap.bitmaps[6] = Cache.system("TileC")
    else
      tile7 = Cache_Swap_Tiles.swap($tileC + ".png") rescue nil
      @ex_tilemap.bitmaps[6] = tile7 if $tileC != nil
    end

    #tileD
    if $tileD == "empty::*::"
      @ex_tilemap.bitmaps[7] = Cache.system("TileD")
    else
      tile8 = Cache_Swap_Tiles.swap($tileD + ".png") rescue nil
      @ex_tilemap.bitmaps[7] = tile8 if $tileD != nil
    end

    #tileE
    if $tileE == "empty::*::"
      @ex_tilemap.bitmaps[8] = Cache.system("TileE")
    else
      tile9 = Cache_Swap_Tiles.swap($tileE + ".png") rescue nil
      @ex_tilemap.bitmaps[8] = tile9 if $tileE != nil
    end
  end
end